<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link rel="stylesheet" type="text/css" href="/Public/uploadfy/uploadify.css" />
    <script type="text/javascript" src="/Public/uploadfy/jquery.uploadify.min.js"></script>
    <style>
        #dg{
            height: 100%;;
        }
    </style>
</block>
<block name="bdoy">
    <body>
    <div id="log_window" class="easyui-window" data-options="closed:true" style="width:1090px;height:530px;">
        <iframe id="window_iframe" style="width:1070px;height:486px;"></iframe>
    </div>
    <table id="grid_machine_log"></table>
    <div id="grid_machine_log_ToolBar" style="padding:5px;height:auto">
        <div id="queryParamZone_machine_log">
            <form id="queryForm_Machinelog" method="post" action="">
                <div>
                    <table>
                        <tr>
                            <td>泵站：</td>
                            <td><input id="ps_id_combox_2" name="ps_id"></td>
                            <td>格栅机名称：</td>
                            <td><select class="easyui-combobox" id="macid" name="macid" valueField="id" textField="scrmach_number" data-options="prompt:'{:LANG('pls_input')}'" style="width: 100px;"></select></td>
                            <td>设备状态：</td>
                            <td>
                                <select name="status" style="width: 80px;">
                                    {:device_status_option()}
                                </select>
                            </td>
                            <td><span><a id="btnQueryMachinelog" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a></span></td>
<!--                            <td><a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="javascript:$('#queryForm_Machinelog').form('clear');">重置</a></td>-->
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>
                                <div id="search_tag_content" style="width: 1000px;"></div>
                            </td>
                        </tr>
                    </table>
                </div>
            </form>
        </div>
    </div>

    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        //$.noConflict();
        $(window).resize(function() {
            $('#grid_machine_log').datagrid('resize');
        });

        function clearmachinelogForm(){
            $('#machinelogForm').form('clear');
        }

        function clearQueryParamZone(){
            $('#queryForm_Machinelog').form('clear');
        }

        $(function(){
            $('#ps_id_combox_2').combobox({
                url:'/Manage/AdminPumpStation/get_all_combox',
                valueField:'id',
                textField:'name',
                width:180,
                multiple:true,
                prompt:'支持多选',
                onSelect: function (record){
                    var text = record.name;
                    if(record.name=='全部'){
                        text = '全部泵站';
                    }
                    create_search_tag(text, 'ps_id', record.id);
                    $('#macid').combobox('clear');
                    $('#macid').combobox('reload','/Manage/AdminPumpMachine/get_all_machine?ps_id='+get_search_tag_ids('ps_id'));
                    $(this).combobox('clear');
                    $('#grid_machine_log').datagrid('resize');
                }
            });
            $('#macid').combobox({
                url:'/Manage/AdminPumpMachine/get_all_machine?ps_id=',
                valueField:'id',
                textField:'scrmach_number',
                width:100,
                multiple:true,
                prompt:'支持多选',
                onSelect: function (record){
                    var text = record.scrmach_number;
                    if(record.scrmach_number=='全部'){
                        text = '全部格栅机';
                    }
                    create_search_tag(text, 'f_id', record.id);
                    $(this).combobox('clear');
                    $('#grid_machine_log').datagrid('resize');
                }
            });
            $('#grid_machine_log').datagrid({
                //title:'格栅机',
                width: '100%',
                //height: 400,
                fit: true,
                nowrap: false,
                striped: true,
                collapsible:false,
                url:'/Manage/AdminPumpMachine/get_all',
                queryParams:{gen:1,page:1,rows:20},
                method:'get',
                pageNumber:1,
                pageSize:20,
                idField:'id',
                remoteSort: false,
                columns:[[
                    {field:'id',title:'序号',width:60,checkbox:true,hidden:true},
                    {field:'sta_name',title:'泵站名称',width:180,align:'center'},
                    {field:'scrmach_number',title:'格栅机编号',width:100,align:'center'},
                    {field:'mac_start',title:'开机时间',width:140,align:'center'},
                    {field:'mac_off',title:'关机时间',width:140,align:'center'},
                    {field:'error_time',title:'故障时间',width:140,align:'center',hidden:true},
                    {field:'work_time',title:'运行时长<br>(小时)', width:100,align:'center'},
                    {field:'status_text',title:'设备状态',width:120,align:'center'},
                    {field:'work_person',title:'当前执勤人员',width:250,align:'center'},
                    {field:'work_log',title:'运行记录',width:80,align:'center'},
                ]],
                pagination:true,
                rownumbers:true,
                singleSelect:false,
                showFooter: true,
                toolbar: '#grid_machine_log_ToolBar',
                rowStyler: function(index,row){
                    if (row.status < 0){
                        return 'background:#EEEE00;';
                    }
                },
                onLoadSuccess: function(data) {
                    var list = data.rows;
                    if(list[0]!=null&&list[0]['status']<0){
                        $(this).datagrid('showColumn', 'error_time');
                    }
                    $(this).datagrid('resize');
                }
            });

            $('#btnQueryMachinelog').click(function() {
                query_fy_form();
            });
        });

        function query_fy_form(){
            $('#grid_pump').datagrid('resize');
            var obj = $('#queryForm_Machinelog').serializeJson();
            obj['ps_id'] = get_search_tag_ids('ps_id');
            obj['f_id'] = get_search_tag_ids('f_id');
            obj['gen'] = '1';
            $('#grid_machine_log').datagrid('load',obj);
        }

    </script>
</block>
